package com.dmpp.mes.controller;

import com.dmpp.mes.bean.ResponseData;
import com.dmpp.mes.parameterInfo.Station;
import com.dmpp.mes.service.StationService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("Station")
public class StationController {
    @Autowired
    private StationService service;

    @RequestMapping(value = "/FindAll", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData findAll(Integer page, Integer pageSize, Station station) {
        PageHelper.startPage(page, pageSize);
        return service.findAll(station);
    }

    @RequestMapping(value = "/FindByCode", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData findById(String code) {
        return service.findByCode(code);
    }

    @RequestMapping(value = "/Insert", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData insert(Station station) {
        return service.insert(station);
    }

    @RequestMapping(value = "/UpdateByCode", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData updateByCode(Station station) {
        return service.updateByCode(station);
    }

    @RequestMapping(value = "/DeleteByCode", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData deleteByCode(String code) {
        return service.deleteByCode(code);
    }


}
